// NOTE:  never include this file directly; it should only be included
// by bbmem.h and any files which implement MemPool

#ifndef BBMEMPOOL_H
#define BBMEMPOOL_H

#include <stdio.h>

/*
  BBMemPool is an abstract class for a pool interface.  The actual derived
  class which will be returned by CreatePool is determined by which memory
  management library is linked in (currently either SmartHeap or
  the stub library used for Purify).

  Management of a global collection of all pools is done in BBMemPool.cpp
*/
class BBMemPool {
private:
	char const *m_pDescription;

protected:
	// should only be called by implementations of CreatePool
	BBMemPool(const char *pDescription);
	// prevent delete from being used on a MemPool
	virtual ~BBMemPool(void);
	
public:

	// create a new pool with the specified attributes
	// - pDescription must be a static string (it is not copied)
	// - extraInfo can be used for handles or whatever
	// - flags are defined below (MEM_POOL_SHARED...)
	// - szFixed is the threshold for SmartHeap's allocation strategy--
	//   example setting would be sizeof(LinkedListNode) if you expected
	//   to allocate a lot of these fixed-size blocks from this pool
	static BBMemPool *CreatePool(
		const char *pDescription,
		unsigned int flags,
		unsigned int szFixed = 16);
	
	// pool description
	char const *GetDescription(void) const
	{ return m_pDescription; }
};

/* Flags passed to BBMemPool::CreatePool */
#ifndef MEM_POOL_SHARED
#define MEM_POOL_SHARED       0x0001u /* == TRUE for SH 1.5 compatibility  */
#define MEM_POOL_SERIALIZE    0x0002u /* pool used in more than one thread */
#define MEM_POOL_VIRTUAL_LOCK 0x0004u /* pool is locked in physical memory */
#define MEM_POOL_ZEROINIT     0x0008u /* malloc/new from pool zero-inits   */
#define MEM_POOL_DEFAULT      0x8000u /* pool with default characteristics */
#endif


#endif // BBMEMPOOL_H
